<?

//$res = json_encode(array('status' => false));
//dbdebug();

//$_POST = array('q11' => array(1,2), 'q12' => array(3), 'q13' => array(4));

//debug($_POST);

$res = array();
foreach($_POST as $q => $qa) {
	if (preg_match('/q([\d-]+)/', $q, $m) && ($qid = gccHuuid($m[1])))
		$res[] = array('id' => $qid, 'answers' => $qa);
}

//debug($res);
$val = gccStoreInterview(array('list' => $res));
//debug($val);


if ($val['status'] == 'ok') {
	$res = $val['raw'];
} else {
	$res = array('status' => false, 'data' => $val);
}


header("Content-Type: application/json; charset=utf-8");
print json_encode($res);

exit;
